package cn.cycleif.enums;

import com.baomidou.mybatisplus.annotation.IEnum;
import com.fasterxml.jackson.annotation.JsonValue;
import lombok.Getter;

@Getter
public enum VoteStatusEnum implements IEnum<Integer> {

  NOTHING(0, "无", "NOTHING"),
  AGREE(1, "赞", "AGREE"),
  DISAGREE(2, "踩", "DISAGREE");

  @JsonValue
  private final int    code;
  private final String desc;
  private final String sign;

  VoteStatusEnum(int code, String desc, String sign) {
    this.code = code;
    this.desc = desc;
    this.sign = sign;
  }

  public static VoteStatusEnum fromCode(Integer code) {
    for (VoteStatusEnum statusEnum : VoteStatusEnum.values()) {
      if (statusEnum.getValue()
                    .equals(code)) {
        return statusEnum;
      }
    }
    return null;
  }

  @Override
  public Integer getValue() {
    return this.code;
  }
}
